#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int* masterMind(char* solution, char* guess, int* returnSize)
{
    int* ret = malloc(sizeof(int) * 2);
    int count1 = 0;
    int count2 = 0;
    *returnSize = 2;
    int len = strlen(solution);
    int mark1[] = { 0,0,0,0 };
    int mark2[] = { 0,0,0,0 };
    int i = 0;
    //猜中
    for (i = 0; i < len; i++)
    {
        if (solution[i] == guess[i])
        {
            count1++;
            mark1[i] = 1;
            mark2[i] = 1;
        }
    }
    //伪猜中
    for (i = 0; i < len; i++)
    {
        if (mark1[i] == 0)
        {
            int j = 0;
            for (j = 0; j < len; j++)
            {
                if (solution[i] == guess[j] && mark2[j] == 0)
                {
                    count2++;
                    mark2[j] = 1;
                    break;
                }
            }
        }
    }
    ret[0] = count1;
    ret[1] = count2;
    return ret;
}

int main()
{
    char solution[] = "RGRB";
    char guess[] = "BBBY";
    int a = 2;
    int* p = masterMind(solution, guess, &a);
    int i = 0;
    for (i = 0; i < a; i++)
    {
        printf("%d ", *(p + i));
    }
    return 0;
}
